package io.renren.common.utils;

import com.p6spy.engine.common.P6Util;
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
import org.apache.commons.lang3.StringUtils;

/**
 * P6Spy日志格式
 *
 * @author 40659
 * @since 2025/1/22 15:06
 */
public class P6SpyLogger implements MessageFormattingStrategy {

    public P6SpyLogger() {
    }

    @Override
    public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
        String newSql = StringUtils.normalizeSpace(P6Util.singleLine(sql));
        return elapsed + "ms " + "|" + newSql;
    }
}
